package com.wgts.wgts.tools;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;

/*
 *
 *
 *   data:2018/10/1713:21
 *
 */public class CustomImageView {
   private CustomImageView(){}
   private static class SingleTonHolder{
       private static final CustomImageView _INSTANCE = new CustomImageView();
   }
   public static CustomImageView getInstance(){
       return SingleTonHolder._INSTANCE;
   }

   public void customImage(Context context, ImageView imageView, double ratio){
       WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
       int iWidth = wm.getDefaultDisplay().getWidth();
       int iHeight = (int)(iWidth*ratio);
       ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
       layoutParams.width = iWidth;
       layoutParams.height = iHeight;
       imageView.setLayoutParams(layoutParams);
   }
   public void customView(Context context, View view, double ratio){
       WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
       int iWidth = wm.getDefaultDisplay().getWidth();
       int iHeight = (int)(iWidth*ratio);
       ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
       layoutParams.width = iWidth;
       layoutParams.height = iHeight;
       view.setLayoutParams(layoutParams);
   }


}
